import React from "react";
import ReactDOM from "react-dom/client";
import { BrowserRouter, Router, Routes, Route, Outlet } from "react-router-dom";
import Layout from "@/pages/Layout/index.jsx";
import Home from "@/pages/Home/index.jsx";
import AboutUs from "@/pages/aboutUs/index.jsx";
import ProductList from "@/pages/productList/index.jsx";
import ProductDetails from "@/pages/productDetails/index.jsx";
import NewsUpdate from "@/pages/newsUpdate/index.jsx";
import NewsDetails from "@/pages/newsDetails/index.jsx";
import ContactUs from "@/pages/contactUs/index.jsx";
import OnlineMessageLeave from "@/pages/onlineMessageLeave/index.jsx";

// React.StrictMode 会执行两次调用页面

ReactDOM.createRoot(document.getElementById("root")).render(
  <BrowserRouter>
    <Routes>
      <Route path="/" element={<Layout />}>
        <Route path="/" index element={<Home />}></Route>
        <Route path="/aboutUs" element={<AboutUs />}></Route>
        <Route path="/contactUs" element={<ContactUs />}></Route>
        <Route path="/productList" element={<ProductList />}></Route>
        <Route path="/newsUpdate" element={<NewsUpdate />}></Route>
        <Route path="/newsDetails" element={<NewsDetails />}></Route>
        <Route
          path="/onlineMessageLeave"
          element={<OnlineMessageLeave />}
        ></Route>
        <Route path="/productDetails" element={<ProductDetails />}></Route>
      </Route>
    </Routes>
    {<Outlet />}
  </BrowserRouter>
);
